-
Notifications
You must be signed in to change notification settings - Fork 162
add ink v6 contract dry run #1740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Thank you for the PR, I promise to get to this sometime in the next 2 days! |
andrew-ifrita
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long delay here. I have a handful of comments and concerns that need to be addressed before this can be approved and merged.
Aside from the specific points mentioned in the code
- The title mentions "ink! v6" but there is nothing version specific here. The PR description might just need a little more context.
- There are no tests for the new endpoint. This is a hard blocker.
- There are no docs for the new endpoint. This is another hard blocker
| * @param _req | ||
| * @param res | ||
| */ | ||
| private dryRun: IPostRequestHandler<IBodyContractMetadata, IContractDryParams> = async ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we have IPostRequestHandler but it is mounted as a GET handler with
this.safeMountAsyncGetHandlers([['/dry-run', this.dryRun as RequestHandler]]);| protected initRoutes(): void { | ||
| this.router.use(this.path, validateAddress); | ||
| this.safeMountAsyncPostHandlers([['/query', this.callContractQuery as RequestHandler]]); | ||
| this.safeMountAsyncGetHandlers([['/dry-run', this.dryRun as RequestHandler]]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is returning IPostRequestHandler while being mounted as a GET handler.
Which one is it?
| { params: { address }, query: { caller, payValue = '0', inputData } }, | ||
| res, | ||
| ): Promise<void> => { | ||
| const dryRunResult = await this.api.call.reviveApi.call( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a check if reviveApi is available as well as graceful handling if it is not.
| caller: string; | ||
| payValue: string; | ||
| inputData: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any of these values being validated anywhere which can lead to some bugs and poor UX / hard to debug issues.
|
|
||
| export interface IContractDryParams extends Query { | ||
| caller: string; | ||
| payValue: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is meant to be optional, based on the default values that is has above.
| }; | ||
|
|
||
| /** | ||
| * Send a message call to a dry run contract. It defaults to get if nothing is inputted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It defaults to get if nothing is inputted.
Personally this is a bit hard to understand on a first read through. Maybe something like
Execute a dry run contract call without requiring the full ABI
is better?
The current contract interface requires transferring a large ABI file with each call. I am now submitting a new dry api for more lightweight contract queries.